package xkp.lesson2;

/**
 * UserInfo class
 *
 * @author Taoge
 * @date 2016/10/31
 */
public class UserInfo {
    private Integer userId;
    private String userName;


    public UserInfo() {
    }

    public UserInfo(Integer userId, String userName) {
        this.userId = userId;
        this.userName = userName;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                '}';
    }

    /**
     * 按照常理，如果equals的返回值为true，则认为是两个一样的对象。
     * @param obj
     * @return
     */
    @Override
    public boolean equals(Object obj) {
       if(this == obj){
           return true;
       }else if(obj instanceof  UserInfo){
           UserInfo userInfo = (UserInfo) obj;
           if(userInfo.userId.equals(this.userId)&& userInfo.userName.equals(this.userName)){
               return true;
           }
       }
       return false;
    }

    @Override
    public int hashCode() {
        return 31*userId+userName.hashCode();
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
    }

    public static void main(String[] args) {
        {
            int num = 100;
            num = 200;
            num++;
        }
        System.out.println();
        System.out.println();
        System.out.println();
        System.out.println();
    }
}
